/** 
 * File-Name:User.java
 *
 * Created on 2011-6-2 上午11:05:56
 * 
 * @author: Neo (neolimeng@gmail.com)
 * Software Engineering Institute, Peking University, China
 * 
 * Copyright (c) 2009, Peking University
 * 
 *
 */
package site.entity;

import java.util.List;

import neoutil.CommonEntity;
import neoutil.StringEncrypt;

/**
 * Description: User Information.
 * 
 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
 *          University, China
 * @version 1.0 2011-6-2 上午11:05:56
 */
public class User extends CommonEntity {
	public static final int GENDER_MALE = 0;
	public static final int GENDER_FEMALE = 1;
	/**
	 * 昵称（必填，唯一）
	 */
	private String name;
	/**
	 * Email（必填，唯一，注册、登陆、忘记密码使用）
	 */
	private String email;
	/**
	 * 密码（必填）
	 */
	private String password;
	/**
	 * 积分（不需要记录每条积分的来源，所以只需要保存一个总分即可。）
	 */
	private int credit = 0;
	/**
	 * 性别（必填，默认女性）
	 */
	private int gender = GENDER_FEMALE;

	/**
	 * 用户角色（必填，默认为普通用户）
	 */
	private long roleId = Role.USER;
	private Role role;

	/**
	 * 用户头像（默认显示一张默认头像）
	 */
	private String headImageLocation = "DEFAULT_HEAD_IMAGE.png";

	/**
	 * 所在地（可选，默认北京）
	 */
	private String location;
	private String description;
	/**
	 * 专业头衔，例如设计师、数学控等（可选）
	 */
	private String title;
	/**
	 * Blog地址（可选）
	 */
	private String blogUrl;

	/**
	 * 我关注的用户数（增加、删除时加一、减一，系统定时清理不一致。）
	 */
	private int followingCount;
	/**
	 * 关注我的用户数（增加、删除时加一、减一，系统定时清理不一致。）
	 */
	private int followedCount;

	/**
	 * 我获得勋章
	 */
	private List<Badge> badges;

	// === Getters and Setters === //
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = StringEncrypt.encrypt(password);
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public long getRoleId() {
		return roleId;
	}

	public void setRoleId(long roleId) {
		this.roleId = roleId;
	}

	public int getGender() {
		return gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public int getCredit() {
		return credit;
	}

	public void setCredit(int credit) {
		this.credit = credit;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getBlogUrl() {
		return blogUrl;
	}

	public void setBlogUrl(String blogUrl) {
		this.blogUrl = blogUrl;
	}

	public String getHeadImageLocation() {
		return headImageLocation;
	}

	public void setHeadImageLocation(String headImageLocation) {
		this.headImageLocation = headImageLocation;
	}

	public int getFollowingCount() {
		return followingCount;
	}

	public void setFollowingCount(int followingCount) {
		this.followingCount = followingCount;
	}

	public int getFollowedCount() {
		return followedCount;
	}

	public void setFollowedCount(int followedCount) {
		this.followedCount = followedCount;
	}

	public List<Badge> getBadges() {
		return badges;
	}

	public void setBadges(List<Badge> badges) {
		this.badges = badges;
	}
}
